Skip to content

Conversation

@esrakartalOpt
Copy link
Contributor

@esrakartalOpt esrakartalOpt commented Jan 13, 2026

Summary

Implements exponential backoff retry strategy for event dispatching to improve reliability and reduce server load during transient failures.

Changes

  • Batch Event Processor: Added retry logic with exponential backoff (3 attempts: 200ms → 400ms → 800ms, capped at 1s) in background thread to avoid blocking user code
  • ODP Event Manager: Added exponential backoff delays to existing retry loop
  • Constants: Added retry configuration (MAX_RETRIES: 3, INITIAL_RETRY_INTERVAL: 0.2, MAX_RETRY_INTERVAL: 1.0)
  • Tests: Added comprehensive test coverage for retry behavior and exponential backoff

Retry Behavior

  • Retries on: Any StandardError during event dispatch (5xx server errors, timeouts, network errors, etc.)
  • No retry on: 4xx client errors are logged but not retried (handled by EventDispatcher)
  • Max attempts: 3 (1 initial + 2 retries)
  • Backoff intervals: 200ms → 400ms → 800ms (capped at 1 second)

Test plan

PR Checks

Issues

Copy link

@pvcraven pvcraven left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving, but has confusing log message:

In batch_event_processor.rb:199:

"Retrying event dispatch (attempt #{retry_count} of #{max_retries - 1})"
With max_retries = 3 and retry_count = 1, 2:

Logs "attempt 1 of 2" and "attempt 2 of 2"
But there are 3 total attempts (1 initial + 2 retries)
Suggestion: Either:

Change to "attempt #{retry_count + 1} of #{max_retries}" → "attempt 2 of 3", "attempt 3 of 3"
Or "retry #{retry_count} of #{max_retries - 1}" → "retry 1 of 2", "retry 2 of 2"
Same issue in odp_event_manager.rb:245

Copy link
Contributor

@Mat001 Mat001 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants